<template>
  <el-form ref="form" :model="users" label-width="80px">
    <el-form-item label="用户名">
      <el-input v-model="users.name"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="users.pwd"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">登陆</el-button>
    </el-form-item>
  </el-form>

</template>

<script>
  export default {
    data() {
      return {
        users: {
          name: '',
          pwd: ''
        }
      }
    },
    methods: {
      onSubmit() {
        console.log(this.users)
        this.axios({
          url:"login",
          method:"get",
          params:this.users
        }).then((resp)=>{
          this.$message(resp.data.msg);
          if(resp.data.state==0){
            localStorage.setItem("token",resp.data.token);
            localStorage.setItem("realName",resp.data.realName);
            this.$router.push("/home");
          }
        });
      }
    }
  }
</script>

<style scoped>

</style>
